package com.fei.wechat.middlewar.service.impl.admin;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;

import com.fei.wechat.middlewar.api.admin.IAuthorityService;
import com.fei.wechat.middlewar.dao.admin.IAuthorityDao;
import com.fei.wechat.middlewar.mode.entity.admin.Authority;
import com.fei.wechat.middlewar.mode.entity.admin.Role;

/**
 * 描述: 菜单权限业务接口实现层
 * 版权: Copyright (c) 2018 
 * 公司: 飞翔科技 
 * 作者: 张进飞 
 * 版本: 1.0 
 * 创建日期: 2018年6月8日 
 * 创建时间: 下午11:06:05
 */
public class AuthorityServiceImpl implements IAuthorityService
{
    
    /**
     * 日志
     */
    private static final Logger LOGGER = Logger.getLogger(AuthorityServiceImpl.class);
    
    @Autowired
    private IAuthorityDao authorityDao;
    
    @Override
    public Authority queryAuthority(Authority authority)
    {
        return authorityDao.queryAuthority(authority);
    }
    
    @Override
    public List<Authority> queryAuthorityList(Authority authority)
    {
        return authorityDao.queryAuthorityList(authority);
    }
    
    @Override
    public List<Authority> queryAllAuthority()
    {
        return authorityDao.queryAllAuthority();
    }
    
    @Override
    public List<Authority> queryAuthoritiesByRoles(Role roles)
    {
        List<Authority> authoritys = null;
        if (null != roles)
        {
            try
            {
                authoritys = authorityDao.queryAuthoritiesByRoleId(roles.getId());
            }
            catch (Exception e)
            {
                LOGGER.error("<== 根据角色ID，查询，角色对应菜单权限，异常：{}", e);
                e.printStackTrace();
            }
        }
        return authoritys;
    }
    
}
